import React, {Component} from 'react';
import {baseUrl} from "../../utiles/baseUrl";
import styles from './index.module.css'
import {withRouter} from 'react-router-dom'



class HouseItem extends Component {
    houseDetail = (value)=> {
        this.props.history.push(`/housedetail/${value}`)
    };


    render() {

        const {houseList,onDelete} = this.props;
        // console.log(this.props);
        // console.log(houseList);
        return (
                <div className={styles.house}>
                    {/*房屋结构*/}
                    {
                        houseList.map(item => {
                            return <div className={styles.houseItems}
                                        key={item.houseCode}
                                        onClick={onDelete ? () => onDelete(item.houseCode) : ()=>this.houseDetail(item.houseCode)}
                                      >
                                <div className={styles.imgWrap}>
                                    <img className={styles.img} src={baseUrl + item.houseImg} alt=""/>
                                </div>
                                <div className={styles.content}>
                                    <h3 className={styles.title}>
                                        {item.title}
                                    </h3>
                                    <div className={styles.desc}>
                                        {item.desc}
                                    </div>
                                    <div>
                                        {item.tags.map(tag => {
                                            return <span key={tag}
                                                         className={[styles.tag, styles.tag1].join(' ')}>{tag}</span>
                                        })}
                                    </div>
                                    <div className={styles.price}>
                                        <span className={styles.priceNum}>{item.price}</span>元/月
                                    </div>
                                </div>
                            </div>
                        })
                    }
                </div>
        );
    }
}

export default withRouter(HouseItem);
